<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Wall
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 * @version    $Id: Twitter.php 2011-04-26 11:18:13 michael $
 * @author     Michael
 */

/**
 * @category   Application_Extensions
 * @package    Wall
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 */

class Wall_Form_Service_Twitter extends Wall_Form_Subform {
	
	public function init() {
		$this->setTitle ( 'WALL_TWITTER_FORM_TITLE' );
		$this->setDescription ( 'WALL_TWITTER_FORM_DESCRIPTION' );
		
		$this->addElement ( 'Checkbox', 'enabled', array ('description' => 'WALL_TWITTER_FORM_ENABLED', 'onclick' => '$$("#consumerkey-wrapper, #consumersecret-wrapper").set("style", "opacity:" + (this.checked) ? 1 : 0.7);$$("#consumerkey-wrapper input, #consumersecret-wrapper input").set("disabled", !this.checked);' ) );
		
		$this->addElement ( 'Text', 'consumerkey', array ('label' => 'WALL_TWITTER_CLIENT_ID', 'description' => 'WALL_TWITTER_CLIENT_ID_DESCRIPTION' ) );
		
		$this->addElement ( 'Text', 'consumersecret', array ('label' => 'WALL_TWITTER_CLIENT_SECRET', 'description' => 'WALL_TWITTER_CLIENT_SECRET_DESCRIPTION' ) );
	
	}
	
	public function setDefaults(array $values) {
		if (! empty ( $values ['enabled'] )) {
			$this->consumerkey->getDecorator ( 'HtmlTag2' )->setOption ( 'style', 'opacity:1' );
			$this->consumersecret->getDecorator ( 'HtmlTag2' )->setOption ( 'style', 'opacity:1' );
			$this->consumerkey->setOptions ( array ('disabled' => null ) );
			$this->consumersecret->setOptions ( array ('disabled' => null ) );
		} else {
			$this->consumerkey->getDecorator ( 'HtmlTag2' )->setOption ( 'style', 'opacity:0.7' );
			$this->consumersecret->getDecorator ( 'HtmlTag2' )->setOption ( 'style', 'opacity:0.7' );
			$this->consumerkey->setOptions ( array ('disabled' => 'disabled' ) );
			$this->consumersecret->setOptions ( array ('disabled' => 'disabled' ) );
		}
		
		return parent::setDefaults ( $values );
	}

}